Conversation
|
Code fixes and commit comments created by AI, needs review. |
|
@ThomasWaldmann, can you please explain the problem behind this PR in a few words? |
|
@UlrichB22 added AI commit comments (Gemini 3 Pro (high)). These were freshly generated, just looking at the changes. |
4bb1652 to
af39679
Compare
Previously, when iter() encountered a non-Element child (like a text string), it would yield it unconditionally, even if the caller was searching for a specific tag (e.g., .//c).
```
def test_Element_findall_dotslashslash():
c1 = Element('c')
c2 = Element('c')
text = "text"
b1 = Element('b', children=(c1, text, c2))
b2 = Element('b')
a1 = Element('a', children=(b1, b2, ))
result = list(a1.findall('.//c'))
> assert len(result) == 2
E AssertionError: assert 3 == 2
E + where 3 = len([<Element 'c' at 1056c4450>, 'text', <Element 'c' at 1056c4810>])
src/emeraldtree/tests/test_tree.py:208: AssertionError
```
The fix ensures that non-Element children are only yielded if no tag filter is specified (tag is None).
This commit implements robust support for the .. (parent) XPath selector. Tree Structure Changes: It adds a _parent attribute to the Element class. The init method and all list-modification methods are updated to automatically maintain this parent pointer when children are modified. Path Resolution: It updates ElementPath.py to use these _parent pointers when resolving. If a parent pointer is missing (e.g., for objects not attached to the current context), it falls back to building a temporary parent map by traversing from the root.
af39679 to
f408550
Compare
|
Found an issue, fixed it, force pushed. |
|
Thanks for the commit comments. I understand the The If you like, I can test the first fix together with Moin and also include a break for the second query type. |
- Implemented 1-based indexing for predicates (e.g. tag[1]). - Raise SyntaxError for invalid indices (< 1) to match xml.etree behavior. - Enabled test_Element_findall_position and added test_Element_findall_position_invalid.
No description provided.